package com.dingwen.payment.controller;


import com.dingwen.commons.entity.Payment;
import com.dingwen.payment.service.IPaymentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dingwen
 * @since 2021-07-05
 */
@RestController
@RequestMapping("/payment")
public class PaymentController {

    private final IPaymentService paymentService;

    @Value("${server.port}")
    private Integer port;

    @Autowired
    public PaymentController(IPaymentService paymentService) {
        this.paymentService = paymentService;
    }

    /**
     * 保存
     *
     * @param payment 付款
     * @return {@link Object}
     */
    @PostMapping("")
   public Object save(@RequestBody Payment payment){
        return paymentService.save(payment);
   }


    /**
     * 找到
     *
     * @param id id
     * @return {@link Object}
     */
    @GetMapping("/{id}")
   public Object find(@PathVariable Long id){
        System.out.println("port = " + port);
        return paymentService.getById(id);
   }
}
